package com.aaa.service.system.impl;

import cn.hutool.core.util.ObjectUtil;

import com.aaa.dao.system.DeptDao;
import com.aaa.entity.system.Dept;
import com.aaa.entity.system.PageOrder;
import com.aaa.entity.system.User;
import com.aaa.service.system.DeptService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：肖成杰（1752167034@qq.com）
 * @date ：Created in 2022/8/10 8:37
 * @description：
 * @modified By：
 * @version:
 */

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptDao deptDao;


    @Override
    public Page query(PageOrder pageOrder, Dept dept) {

        PageHelper.startPage(pageOrder.getPage(), pageOrder.getLimit());
        if (ObjectUtil.isNotEmpty(pageOrder.getField())) {
            PageHelper.orderBy(pageOrder.getFieldOrder());
        }
        List<Dept> list = deptDao.query(dept);
        Page pageResult = (Page) list;
        return pageResult;
    }

    @Override
    public List<Dept> quaryAll() {
        return deptDao.queryAll();
    }

    @Override
    public boolean delete(int[] deptId) {
        return deptDao.delete(deptId);
    }

    @Override
    public boolean insertDept(Dept dept) {
        return deptDao.insertDept(dept);
    }

    @Override
    public boolean updateDept(Dept dept) {
        return deptDao.updateDept(dept);
    }

    /**
     * 查询部门名称是否被使用
     *
     * @param deptName
     * @return
     */
    @Override
    public List<Dept> queryByName(String deptName) {
        return deptDao.queryByName(deptName);
    }
}